import { createRouter, createWebHistory } from 'vue-router'
import BookInfo from '@/views/manager/bookInfo.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  scrollBehavior() {
    // 始终滚动到顶部
    return { top: 0 }
  },
  routes: [
    {
      path: '/login',
      component: () => import('@/views/login/login.vue')
    },
    {
      path: '/emplogin',
      component: () => import('@/views/login/empLogin.vue')
    },
    {
      path: '/index',
      component: () => import('@/views/index/index.vue'),
      redirect: '/',
      children: [
        {
          path: '/category/:id',
          component: () => import('@/views/category/category.vue')
        },
        {
          path: '/',
          component: () => import('@/views/home/home.vue')
        },
        {
          path: '/detail/:id',
          component: () => import('@/views/detail/detail.vue')
        },
        {
          path: '/cart',
          component: () => import('@/views/cart/cart.vue')
        },
        {
          path: '/user',
          component: () => import('@/views/user/user.vue')
        }
      ]
    },
    {
      path: '/manager',
      component: () => import('@/views/manager/mIndex.vue'),
      redirect: '/bookInfo',
      children: [
        {
          path: '/userInfo',
          component: () => import('@/views/manager/userInfo.vue')
        },
        {
          path: '/empInfo',
          component: () => import('@/views/manager/empInfo.vue')
        },
        {
          path: '/bookInfo',
          component: BookInfo
        },
        {
          path: '/typeInfo',
          component: () => import('@/views/manager/typeInfo.vue')
        },
        {
          path: '/bannerInfo',
          component: () => import('@/views/manager/bannerInfo.vue')
        },
        {
          path: '/orderInfo',
          component: () => import('@/views/manager/orderInfo.vue')
        },
        {
          path: '/hotInfo',
          component: () => import('@/views/manager/hotInfo.vue')
        }
      ]
    }
  ]
})

export default router
